#include <stdio.h>

int main()
{
  FILE *fp = fopen("log.txt","a");
  if(fp == NULL)
  {
    perror("fopen");
    return 1;
  }
  char buffer[1024];
  
  const char * message = "hello Linux";
  int i =0;
  while(i<10)
  {
    snprintf(buffer,sizeof(buffer),"%s:%d\n",message,i);
    fputs(buffer,fp);
    i++;
  }
  fclose(fp);
  return 0; 
}
